import { messageList, unreadNum, readMsg } from '@/api/Classify'

export default defineStore('useClassify', {
  state: () => ({}),
  getters: {},
  actions: {
    //未读消息列表
    async getMessageList() {
      let url = $globalRequestUrl({
        url: messageList,
      })

      try {
        const rep = await $globalRequest(url, {}, { method: 'GET' })
        return rep
      } catch (error) {
        return error
      }
    },

    //消息未读数量
    async unreadNum() {
      let url = $globalRequestUrl({
        url: unreadNum,
      })

      try {
        const rep = await $globalRequest(url, {}, { method: 'GET' })
        return rep
      } catch (error) {
        return error
      }
    },

    //消息已读
    async readMsg(id) {
      let url = $globalRequestUrl({
        url: readMsg + `/${id}`,
      })

      try {
        const rep = await $globalRequest(url, {}, { method: 'GET' })
        return rep
      } catch (error) {
        return error
      }
    },
  },
})
